public class MyCirularQueue {
    //循环队列
    class MyCircularQueue{
        public int[] elem;
        public int first;
        public int last;

        public MyCircularQueue(int k) {
            elem=new int[k+1];

        }
        public boolean enQueue(int value){
            if (isFull()){
                return false;
            }
            elem[last]=value;
            last=(last+1)%elem.length;
            return true;
        }
        public boolean deQueue(){
            if (isFull()){
                return false;
            }
            first=(first+1)%elem.length;
            return true;
        }
        //得到队头元素
        public int Front(){
            if (isFull()){
                return -1;
            }
            return elem[first];

        }
        public int Rear(){
            if (isEmpty()){
                return -1;
            }
            int index=(last==0)? elem.length-1 :last-1;
                return elem[index];
        }
        public boolean isEmpty(){
            return  first==last;
        }
        public boolean isFull(){
            return (last+1)% elem.length==first;
        }



    }
}
